#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ep emplace
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

int read() {
	int x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;
using tl = tuple < int, int, int >;

const int N = 5e5 + 10;

pii p[N];
int n, d, ans;

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	n = in, d = in; rep(i, 1, n) p[i].fi = in, p[i].se = in;
	sort(p + 1, p + n + 1, [](auto a, auto b) { return max(a.fi, a.se) ^ max(b.fi, b.se) ? max(a.fi, a.se) < max(b.fi, b.se) : a.fi < b.fi; });
	rep(i, 1, n)
		if(p[i].fi >= d)
			ans++, d = max(d, p[i].se);
	printf("%d\n", ans);
	return 0;
}
